Ext.define('Seq.svg.Drag', {
	        extend : 'Seq.svg.Base',

	        boxCls : {
		        fill : 'none',
		        stroke : '#55aaff',
		        'stroke-width' : 1,
		        'stroke-linecap' : 'round',
		        'stroke-linejoin' : 'round',
		        'stroke-dasharray' : "5,5"
	        },

	        startXy : null, // 起点
	        box : null, // model的选中框阴影, 在移动中绘制
	        selected : [], // 选中的model阴影, 在移动中绘制

	        start : function(e) {
		        var me = this;
		        me.cancel();
		        me.startXy = me.getXy(e);
	        },

	        move : function(e) {
		        var me = this;
		        if (me.startXy) {
			        if (me.box) {
				        me.transformShadow(e);
			        } else {
				        me.initShadow(e);
			        }
		        }
	        },

	        end : function(e) {
		        var me = this;
		        if (me.box) {
			        me.transformSelected(e);
		        }
		        me.cancel();
	        },

	        cancel : function() {
		        var me = this;
		        if (me.box) {
			        me.box.remove();
			        me.box = null;
		        }
		        // 移除选中的MODEL阴影
		        Ext.each(me.selected, function(model) {
			                model.remove();
		                });
		        me.selected = [];
		        me.startXy = null;
	        },

	        initShadow : function(e) {
		        var me = this, xy = me.getXy(e);
		        if (0 > Math.abs(xy.x - me.startXy.x) || 0 > Math.abs(xy.y - me.startXy.y)) {
			        return;
		        }

		        var paper = me.canvas.svg.paper, selectBox = me.canvas.selectBox, bbox = selectBox.box.getBBox();
		        me.box = paper.rect(bbox.x, bbox.y, bbox.w, bbox.h).attr(me.boxCls);
		        me.box.originalMatrix = me.box.transform().localMatrix;

		        me.selected = [];
		        Ext.each(selectBox.selected, function(model) {
			                var clone = model.clone().attr({
				                        opacity : 0.6,
				                        "stroke-opacity" : 0.6,
				                        "fill-opacity" : 0.6
			                        });
			                clone.originalMatrix = clone.transform().localMatrix;
			                me.selected.push(clone);
		                });
	        },

	        transformItems : function(items, ox, oy) {
		        for (var i = 0, len = items.length; i < len; i++) {
			        var item = items[i], m = new Snap.Matrix();
			        var matrix = item.originalMatrix ? item.originalMatrix.clone() : item.transform().localMatrix;
			        
			        m.translate(ox / matrix.a, oy / matrix.d);
			        matrix.add(m);
			        item.transform(matrix);
		        }
	        },

	        transformShadow : function(e) {
		        var me = this, xy = me.getXy(e);
		        var ox = xy.x - me.startXy.x, oy = xy.y - me.startXy.y;

		        me.transformItems([me.box], ox, oy);
		        me.transformItems(me.selected, ox, oy);
	        },

	        transformSelected : function(e) {
		        var me = this, selectBox = me.canvas.selectBox, xy = me.getXy(e);
		        var ox = xy.x - me.startXy.x, oy = xy.y - me.startXy.y;

		        me.transformItems(selectBox.selected, ox, oy);
		        me.transformItems([selectBox.box], ox, oy);
		        me.transformItems(selectBox.subBoxs, ox, oy);
		        me.transformItems(selectBox.anchors, ox, oy);
	        }

        });